package com.cmccgz.udacs_landlord_webapp;

import android.Manifest;
import android.content.DialogInterface;
import android.support.annotation.NonNull;

import com.cmccgz.baselibrary.base.BaseActivity;
import com.cmccgz.baselibrary.base.PermissionUtils;

public class MainActivity extends BaseActivity {

    PermissionUtils.PermissionAskCallback callback ;

    @Override
    protected void initView() {
        callback =  new PermissionUtils.PermissionAskCallback() {
            @Override
            public void hasPermissionDoNext() {

            }
        };
        PermissionUtils.askPermission(this,PermissionUtils.REQUEST_CODE_ASK_PERMISSIONS, callback, Manifest.permission.CALL_PHONE);
    }

    @Override
    protected void initFragment() {

    }

    @Override
    protected void beforePermission() {

    }

    @Override
    protected int setSystemBarColorId() {
        return 0;
    }

    @Override
    protected int setLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == PermissionUtils.REQUEST_CODE_ASK_PERMISSIONS){
            PermissionUtils.handlePermissionRequest(permissions, grantResults, this, callback, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
        }
    }
}
